package com.wxl.common.wiget

import android.content.Context
import android.view.View
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.enums.PopupPosition
import com.lxj.xpopup.impl.AttachListPopupView
import com.lxj.xpopup.interfaces.OnSelectListener
import com.wxl.common.base.AbsActivity
import com.wxl.common.util.DPUtil

class BlastAttachListPopupView(context: Context) : AttachListPopupView(context) {

    override fun getPopupWidth(): Int {
        return popupInfo.atView.width
    }


    companion object {
        fun show(atView: View, listener: OnSelectListener, vararg typeArr: String) {
            val popupView = BlastAttachListPopupView(atView.context)
                .setStringData(typeArr, null)
                .setOffsetXAndY(0, 0)
                .setOnSelectListener(listener)

            (atView.context as AbsActivity).addPop(
                XPopup.Builder(atView.context)
                    .atView(atView)
                    .maxHeight(DPUtil.dip2px(200))
                    .hasShadowBg(false)
                    .popupPosition(PopupPosition.Bottom)
                    .asCustom(popupView)
                    .show()
            )
        }
    }
}